package cn.botter.auth.application.config;

import java.util.Scanner;

/**
 * @BelongsProject: bo-club
 * @BelongsPackage: cn.botter.application.config
 * @Author: 爱写Bug的Botter
 * @CreateTime: 2025-03-23:14:27
 * @Description: 这个程序是计算两个h:m时间的之间差距多少分钟和差距多少h:m的
 * @Version: 1.0
 */
public class TestTimeComperse {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 读取第一个时间
        String startTimeStr = sc.nextLine();
        // 读取第二个时间
        String endTimeStr = sc.nextLine();
        // 调用计算时间差的方法
        int diff = calculateTimeDifference(startTimeStr, endTimeStr);
        System.out.println("两个时间相差 " + diff + " 分钟");
        System.out.println("两个时间相差:" +diff/60+"小时,"+(diff%60)+"分钟");
        sc.close();
    }

    public static int calculateTimeDifference(String startTimeStr, String endTimeStr) {
        // 将输入的时间字符串按冒号分割成小时和分钟
        String[] startTimeParts = startTimeStr.split(":");
        String[] endTimeParts = endTimeStr.split(":");

        // 提取小时和分钟
        int startHours = Integer.parseInt(startTimeParts[0]);
        int startMinutes = Integer.parseInt(startTimeParts[1]);
        int endHours = Integer.parseInt(endTimeParts[0]);
        int endMinutes = Integer.parseInt(endTimeParts[1]);

        // 计算总分钟数
        int totalStartMinutes = startHours * 60 + startMinutes;
        int totalEndMinutes = endHours * 60 + endMinutes;

        // 计算时间差
        return totalEndMinutes - totalStartMinutes;
    }
}
